//
//  File.swift
//
//
//  Created by didi on 2022/9/13.
//

import Foundation
import MolecularObjects

public struct SystemMetadataApi {
    let repository: SystemMetadataRepository

    init(_ repository: SystemMetadataRepository) {
        self.repository = repository
    }
}

public extension SystemMetadataApi {
    func list() async throws -> [Metadata.List] {
        try await repository.list().transform(to: [Metadata.List].self)
    }

    func listFeedItems() async throws -> [Metadata.List] {
        try await repository.listFeedItems().transform(to: [Metadata.List].self)
    }

    func list(_ ids: [UUID]) async throws -> [Metadata.List] {
        try await repository.get(ids).transform(to: [Metadata.List].self)
    }

    func get(_ id: UUID) async throws -> Metadata.Detail? {
        try await repository.get(id).transform(to: Metadata.Detail.self)
    }

    func get(_ ids: [UUID]) async throws -> [Metadata.Detail] {
        try await repository.get(ids).transform(to: [Metadata.Detail].self)
    }
}
